import axios  from './axiosFun';


// 获取Domain地址
export async function getDomain (type) {
    const { data } = await axios.get(
        `/gw/baseapi/uconfig/cfg/${type}`
    );
    return (data || {});
}

/*
 *@functionName: getSection
 *@params:参数
 *@description:根据标签ID获取学段
 *@author: zhaoliuwei
 *@date: 2022-07-29 14:45:30
*/
export async function getSection (datas) {
    const { data } = await axios.get(`${process.env.VUE_APP_NRMS_URL}/urc/v1/tag/getTagDetail`, {
        params: datas
    });
    return data;
}

/*
 *@functionName: getCataloguesList
 *@params:参数
 *@description:获取学科产品列表
 *@author: zhaoliuwei
 *@date: 2022-08-12 15:18:35
*/
export async function getCataloguesList (datas) {
    const { data } = await axios.get(`${process.env.VUE_APP_NRMS_URL}/res/v1/catalogues/list`, {
        params: datas
    });
    return data;
}

/*
 *@functionName: getTypeList
 *@params:参数
 *@description:获取产品类型列表
 *@author: zhaoliuwei
 *@date: 2022-08-03 08:54:33
*/
export async function getTypeList (datas) {
    const { data } = await axios.get(`${process.env.VUE_APP_TEMP_URL}/apptemplate/v1/type/list`, {
        params: datas
    });
    return data;
}

/*
 *@functionName: addAppType
 *@params:参数
 *@description:新增类型
 *@author: zhaoliuwei
 *@date: 2022-08-03 09:11:08
*/
export async function addAppType (params) {
    const { data } = await axios.post(
        `${process.env.VUE_APP_TEMP_URL}/apptemplate/v1/type/add_type`,
        params
    );
    return data;
}
/*
 *@functionName: deleteAppType
 *@params:参数
 *@description:根据ID删除类型
 *@author: zhaoliuwei
 *@date: 2022-08-03 09:52:50
*/
export async function deleteAppType (datas) {
    const { data } = await axios.get(`${process.env.VUE_APP_TEMP_URL}/apptemplate/v1/type/del_type`, {
        params: datas
    });
    return data;
}

/*
 *@functionName: getAppList
 *@params:参数
 *@description:获取产品列表接口
 *@author: zhaoliuwei
 *@date: 2022-08-03 13:53:53
*/
export async function getAppList (datas) {
    const { data } = await axios.get(`${process.env.VUE_APP_TEMP_URL}/apptemplate/v1/app/list`, {
        params: datas
    });
    return data;
}

/*
 *@functionName: addProduct
 *@params:参数
 *@description:新增产品
 *@author: zhaoliuwei
 *@date: 2022-08-03 14:17:26
*/
export async function addProduct (params) {
    const { data } = await axios.post(
        `${process.env.VUE_APP_TEMP_URL}/apptemplate/v1/app/add`,
        params
    );
    return data;
}

/*
 *@functionName: deleteAppType
 *@params:参数
 *@description:根据ID删除产品
 *@author: zhaoliuwei
 *@date: 2022-08-03 09:52:50
*/
export async function deleteProduct (datas) {
    const { data } = await axios.get(`${process.env.VUE_APP_TEMP_URL}/apptemplate/v1/app/del`, {
        params: datas
    });
    return data;
}

/*
 *@functionName: getTemplateList
 *@params:参数
 *@description:获取模板列表接口
 *@author: zhaoliuwei
 *@date: 2022-08-03 14:56:30
*/
export async function getTemplateList (datas) {
    const { data } = await axios.get(`${process.env.VUE_APP_TEMP_URL}/apptemplate/v1/template/list`, {
        params: datas
    });
    return data;
}

/*
 *@functionName: addTemplate
 *@params:参数
 *@description:添加模板
 *@author: zhaoliuwei
 *@date: 2022-08-03 16:21:20
*/
export async function addTemplate (params) {
    const { data } = await axios.post(
        `${process.env.VUE_APP_TEMP_URL}/apptemplate/v1/template/add_template`,
        params
    );
    return data;
}

/*
 *@functionName: copyTemplate
 *@params:参数
 *@description:复制模板
 *@author: zhaoliuwei
 *@date: 2022-08-05 13:39:32
*/
export async function copyTemplate (datas) {
    const { data } = await axios.get(`${process.env.VUE_APP_TEMP_URL}/apptemplate/v1/template/copy`, {
        params: datas
    });
    return data;
}

/*
 *@functionName: publistTemplate
 *@params:参数
 *@description:发布模板
 *@author: zhaoliuwei
 *@date: 2022-08-05 14:18:30
*/
export async function publistTemplate (params) {
    const { data } = await axios.post(
        `${process.env.VUE_APP_TEMP_URL}/apptemplate/v1/template/publish`,
        params
    );
    return data;
}

/*
 *@functionName: deleteTemplate
 *@params:参数
 *@description:删除模板
 *@author: zhaoliuwei
 *@date: 2022-08-05 13:39:32
*/
export async function deleteTemplate (datas) {
    const { data } = await axios.get(`${process.env.VUE_APP_TEMP_URL}/apptemplate/v1/template/del_template`, {
        params: datas
    });
    return data;
}

/*
 *@functionName: getDomainList
 *@params:参数
 *@description:获取域名列表
 *@author: zhaoliuwei
 *@date: 2022-08-05 14:42:05
*/
export async function getDomainList (params) {
    const { data } = await axios.post(
        `${process.env.VUE_APP_PORTA_URL}/protal/v1/platform/plat_domain_list`,
        params
    );
    return data;
}

/*
 *@functionName: saveRelationPages
 *@params:参数
 *@description:保存模板选择的管理页面
 *@author: zhaoliuwei
 *@date: 2022-08-08 10:57:10
*/
export async function saveRelationPages (params) {
    const { data } = await axios.post(
        `${process.env.VUE_APP_TEMP_URL}/apptemplate/v1/template/decorate_page`,
        params
    );
    return data;
}

/*
 *@functionName: pageversionByTemplate
 *@params:参数
 *@description:根据模板获取最新版本已关联页面的信息
 *@author: zhaoliuwei
 *@date: 2022-08-08 11:34:40
*/
export async function pageversionByTemplate (datas) {
    const { data } = await axios.get(`${process.env.VUE_APP_TEMP_URL}/apptemplate/v1/template/pageversion_by_template`, {
        params: datas
    });
    return data;
}

/*
 *@functionName: toppingTemplate
 *@params:参数
 *@description:置顶模板
 *@author: zhaoliuwei
 *@date: 2023-12-28 09:42:32
*/
export async function toppingTemplate (datas) {
    const { data } = await axios.get(`${process.env.VUE_APP_TEMP_URL}/apptemplate/v1/template/top`, {
        params: datas
    });
    return data;
}

/*
 *@functionName: getPageList
 *@params:参数
 *@description:获取页面列表接口
 *@author: zhaoliuwei
 *@date: 2022-08-03 14:56:30
*/
export async function getPageList (datas) {
    const { data } = await axios.get(`${process.env.VUE_APP_TEMP_URL}/apptemplate/v1/page/list`, {
        params: datas
    });
    return data;
}

/*
 *@functionName: copyPageList
 *@params:参数
 *@description:复制页面
 *@author: zhaoliuwei
 *@date: 2022-08-08 14:14:10
*/
export async function copyPageList (datas) {
    const { data } = await axios.get(`${process.env.VUE_APP_TEMP_URL}/apptemplate/v1/page/copy_by_id`, {
        params: datas
    });
    return data;
}

/*
 *@functionName: deletePageList
 *@params:参数
 *@description:根据ID删除对应模板
 *@author: zhaoliuwei
 *@date: 2022-08-08 14:20:10
*/
export async function deletePageList (params) {
    const { data } = await axios({
        method: 'post',
        url: `${process.env.VUE_APP_TEMP_URL}/apptemplate/v1/page/del_by_id`,
        params,
        headers: { "Content-Type": "application/x-www-form-urlencoded" },
    });
    return data;
}

/*
 *@functionName: getTemplateTagLevel
 *@params:参数
 *@description:根据id获取学段和科目
 *@author: zhaoliuwei
 *@date: 2022-08-09 11:03:20
*/
export async function getTemplateTagLevel (datas) {
    const { data } = await axios.get(`${process.env.VUE_APP_NRMS_URL}/urc/v1/template/getTemplateTagLevel`, {
        params: datas
    });
    return data;
}

/*
 *@functionName: savePages
 *@params:参数
 *@description:新增页面
 *@author: zhaoliuwei
 *@date: 2022-08-09 14:01:40
*/
export async function savePages (params) {
    const { data } = await axios.post(
        `${process.env.VUE_APP_TEMP_URL}/apptemplate/v1/page/save`,
        params
    );
    return data;
}

/*
 *@functionName: getPageDetail
 *@params:参数
 *@description:根据页面id获取页面详情
 *@author: zhaoliuwei
 *@date: 2022-08-09 16:07:45
*/
export async function getPageDetail (datas) {
    const { data } = await axios.get(`${process.env.VUE_APP_TEMP_URL}/apptemplate/v1/page/get_by_id`, {
        params: datas
    });
    return data;
}

/*
 *@functionName: getPageDataList
 *@params:参数
 *@description:根据页面id获取页面数据列表
 *@author: zhaoliuwei
 *@date: 2022-08-09 16:07:45
*/
export async function getPageDataList (datas) {
    const { data } = await axios.get(`${process.env.VUE_APP_TEMP_URL}/apptemplate/v1/page_data/list_by_page_id`, {
        params: datas
    });
    return data;
}

/*
 *@functionName: getPageDomainList
 *@params:参数
 *@description:根据产品、域名、模板编码获取发布的模板数据接口
 *@author: zhaoliuwei
 *@date: 2022-08-09 17:52:20
*/
export async function getPageDomainList (datas) {
    const { data } = await axios.get(`${process.env.VUE_APP_TEMP_URL}/apptemplate/v1/release/get_list`, {
        params: datas
    });
    return data;
}

/*
 *@functionName: decoratePages
 *@params:参数
 *@description:保存页面装修
 *@author: zhaoliuwei
 *@date: 2022-08-09 21:03:40
*/
export async function saveDecoratePages (params) {
    const { data } = await axios.post(
        `${process.env.VUE_APP_TEMP_URL}/apptemplate/v1/page_data/save`,
        params
    );
    return data;
}

/*
 *@functionName: getPageCustomDetail
 *@params:参数
 *@description:获取页面数据详情接口
 *@author: zhaoliuwei
 *@date: 2022-08-10 08:54:20
*/
export async function getPageCustomDetail (datas) {
    const { data } = await axios.get(`${process.env.VUE_APP_TEMP_URL}/apptemplate/v1/page_data/get_detail`, {
        params: datas
    });
    return data;
}

/*
 *@functionName: getLinkList
 *@params:参数
 *@description:根据产品类型、链接类型获取链接列表接口
 *@author: zhaoliuwei
 *@date: 2022-08-11 10:02:55
*/
export async function getLinkList (datas) {
    const { data } = await axios.get(`${process.env.VUE_APP_TEMP_URL}/apptemplate/v1/links/get_list`, {
        params: datas
    });
    return data;
}

/*
 *@functionName: saveLinkType
 *@params:参数
 *@description:添加页面类型下的链接
 *@author: zhaoliuwei
 *@date: 2022-08-11 11:08:50
*/
export async function saveLinkList (params) {
    const { data } = await axios.post(
        `${process.env.VUE_APP_TEMP_URL}/apptemplate/v1/links/save`,
        params
    );
    return data;
}

/*
 *@functionName: changeTemplateData
 *@params:参数
 *@description:根据域名、产品更换模板数据【已经发布的】（模板回滚可使用）的接口
 *@author: zhaoliuwei
 *@date: 2022-08-11 16:44:44
*/
export async function changeTemplateData (datas) {
    const { data } = await axios.get(`${process.env.VUE_APP_TEMP_URL}/apptemplate/v1/release/change_template_data`, {
        params: datas
    });
    return data;
}

/*
 *@functionName: getAdLocations
 *@params:参数
 *@description:获取推荐位列表
 *@author: zhaoliuwei
 *@date: 2022-08-15 09:50:57
*/
export async function getAdLocations (datas) {
    const { data } = await axios.get(`${process.env.VUE_APP_NBOC_URL}/v1/ad_locations/list`, {
        params: datas
    });
    return data;
}

/*
 *@functionName: getTerminalList
 *@params:参数
 *@description:获取推荐位终端列表
 *@author: zhaoliuwei
 *@date: 2022-08-15 10:40:20
*/
export async function getTerminalList (datas) {
    const { data } = await axios.get(`${process.env.VUE_APP_NBOC_URL}/v1/dict/dictList`, {
        params: datas
    });
    return data;
}

/*
 *@functionName: getChildrenList
 *@params:参数
 *@description:根据学段获取该学段下的科目列表
 *@author: zhaoliuwei
 *@date: 2022-08-15 16:07:50
*/
export async function getChildrenList (params) {
    const { data } = await axios.post(
        `${process.env.VUE_APP_NRMS_URL}/urc/v1/template/getChildrenList`,
        params
    );
    return data;
}

/*
 *@functionName: getFirstLevels
 *@params:参数
 *@description:获取系统模板一级节点数据(学段)
 *@author: zhaoliuwei
 *@date: 2022-08-16 08:55:15
*/
export async function getFirstLevels (datas) {
    const { data } = await axios.get(`${process.env.VUE_APP_NRMS_URL}/urc/v1/template/getFirstLevels`, {
        params: datas
    });
    return data;
}

/*
 *@functionName: getEntityBookList
 *@params:参数
 *@description:书籍管理 列表查询
 *@author: zhaoliuwei
 *@date: 2023-08-01 19:46:15
*/
export async function getEntityBookList (params) {
    const { data } = await axios.get(`${process.env.VUE_APP_NRMS_URL}/res/v1/catalogues/list_book`, {
        params: {
            ...params
        }
    });
    return (data || {}).data;
}

/*
 *@functionName: getTagDetail
 *@params:参数
 *@description:获取标签详情接口
 *@author: zhaoliuwei
 *@date: 2023-08-02 10:14:15
*/
export async function getTagDetail ({ id }) {
    const { data } = await axios.get(`${process.env.VUE_APP_NRMS_URL}/urc/v1/tag/getTagDetail`, { params: { id } });
    return data;
  }